package com.yijianonghu.service.wxwebsite.sannongdongtai;

import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yijianonghu.dal.model.SysBlog;
import com.yijianonghu.dal.model.SysBlogExample;
import com.yijianonghu.util.Constants;

import net.javahub.dao.BaseSqlDao;
import net.javahub.dao.BaseSqlDao.SqlWrapper;
import net.javahub.service.BaseService;

@Service
public class SanNongDongTaiListService extends BaseService<SysBlog, Integer, SysBlogExample> {

	@Autowired
	private BaseSqlDao baseSqlDao;
	
	//首页三农动态的显示
	public List<Map<String, Object>> getSanNongDongTaiListForHomePage() {
		StringBuilder sb=new StringBuilder("select sc.nickname, sb.name from sys_blog sb left join sys_client sc on sb.client_id=sc.id where sb.type=0 ");
		sb.append(" and sb.typename=#{params.sannongdongtai}")
			.append(" and sb.removeflag=0")
			.append(" and sb.include_in_wx=1")
			.append(" and sb.recommend_in_wx=1");
		SqlWrapper sqlWrapper=new SqlWrapper();
		sqlWrapper.addParam("sannongdongtai", Constants.CommonConstants.SAN_NONG_DONG_TAI);
		sqlWrapper.setSqlStatement(sb.toString());
		return baseSqlDao.select(sqlWrapper);
	}
	
	//三农动态列表
	public List<Map<String, Object>> getSanNongDongTaiList() {
		StringBuilder sb=new StringBuilder("select sc.nickname, sb.name from sys_blog sb left join sys_client sc on sb.client_id=sc.id where sb.type=0 ");
		sb.append(" and sb.typename=#{params.sannongdongtai}")
			.append(" and sb.removeflag=0")
			.append(" and sb.include_in_wx=1");
		SqlWrapper sqlWrapper=new SqlWrapper();
		sqlWrapper.addParam("sannongdongtai", Constants.CommonConstants.SAN_NONG_DONG_TAI);
		sqlWrapper.setSqlStatement(sb.toString());
		return baseSqlDao.select(sqlWrapper);
	}
	
}
